package com.example.readfiletest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ZichanModifyActivity extends Activity {

	private TextView codeModifyTv;
	private EditText addressModifyEt;
	private EditText productNameModifyEt;
	private EditText buildAreaModifyEt;
	private EditText brandModifyEt;
	private EditText xinghaoModifyEt;
	private EditText passportNoModifyEt;
	private EditText productNoModifyEt;
	private EditText pandianFlgModifyEt;
	private EditText pandianDateModifyEt;
	
	private Button applyModifyBtn;
	private Button cancelModifyBtn;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_zichan_modify);
		
		codeModifyTv = (TextView) findViewById(R.id.code_modify_tv);
		addressModifyEt = (EditText) findViewById(R.id.adress_modify_et);
		productNameModifyEt = (EditText) findViewById(R.id.zichan_modify_et);
		buildAreaModifyEt = (EditText) findViewById(R.id.buildarea_modify_et);
		brandModifyEt = (EditText) findViewById(R.id.brand_modify_et);
		xinghaoModifyEt = (EditText) findViewById(R.id.xinghao_modify_et);
		passportNoModifyEt = (EditText) findViewById(R.id.passport_modify_et);
		productNoModifyEt = (EditText) findViewById(R.id.productno_modify_et);
		pandianFlgModifyEt = (EditText) findViewById(R.id.ispandian_modify_et);
		pandianDateModifyEt = (EditText) findViewById(R.id.pandian_date_modify_et);
		
		applyModifyBtn = (Button) findViewById(R.id.apply_modify_btn);
		cancelModifyBtn = (Button) findViewById(R.id.cancel_modify_btn);
		
		
		final Product product = new Product();
		
		Intent intent = getIntent();
		final Bundle bundle = intent.getExtras();
		
		int pos = bundle.getInt("pos");
		product.setPos(pos);
		
		String item = bundle.getString("barcode");
		codeModifyTv.setText(item.trim());
		product.setBarCode(item.trim());
		
		item = bundle.getString("productname");
		productNameModifyEt.setText(item.trim());
		
		item = bundle.getString("address");
		addressModifyEt.setText(item.trim());
		
		item = bundle.getString("buildarea");
		buildAreaModifyEt.setText(item.trim());
		
		item = bundle.getString("brand");
		brandModifyEt.setText(item.trim());
		
		item = bundle.getString("xinghao");
		xinghaoModifyEt.setText(item.trim());
		
		item = bundle.getString("passportno");
		passportNoModifyEt.setText(item.trim());
		
		item = bundle.getString("productno");
		productNoModifyEt.setText(item.trim());
		
		item = bundle.getString("pandianflg");
		pandianFlgModifyEt.setText(item.trim());
		
		item = bundle.getString("pandiandate");
		pandianDateModifyEt.setText(item.trim());
		
		applyModifyBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				//Product product = PandianFileUtils.buildProductWithBundle(bundle);
				product.setProductName(productNameModifyEt.getText().toString().trim());
				product.setAddress(addressModifyEt.getText().toString().trim());
				product.setBuildArea(buildAreaModifyEt.getText().toString().trim());
				product.setBrand(brandModifyEt.getText().toString().trim());
				product.setXinghao(xinghaoModifyEt.getText().toString().trim());
				product.setPassportNo(passportNoModifyEt.getText().toString().trim());
				product.setProductNo(productNoModifyEt.getText().toString().trim());
				product.setPandianflg(pandianFlgModifyEt.getText().toString().trim());
				product.setPandianDate(pandianDateModifyEt.getText().toString().trim());
				PandianFileUtils.modifyByRandom(product);
			}
		});
		
		cancelModifyBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
			}
		});
		
		
		
		
	}
	
	

}
